﻿using calculator;

namespace Tree
{
    /// <summary>
    /// Function Node
    /// </summary>
    class FuncNode : Node
    {
        /// <summary>
        /// CTOR
        /// </summary>
        /// <param name="func">Function Pointer</param>
        /// <param name="pNode">Argument for the function</param>
        public FuncNode(FunctionEntry func, Node pNode)
        {
            _pNode = pNode;
            _func = func;
        }
        public override double Result
        {
            get
            {
                return _func.Dofunction(_pNode.Result);
            }
        }


        protected override void Dispose(bool disposing)
        {
            if (!_disposed)
            {
                if (disposing)
                {
                    //disposed managed resource
                    _pNode = null;
                }
                // release unmanaged resource
            }
            _disposed = true;

            // if available, call to base class
            base.Dispose(disposing);
        }


        private FunctionEntry _func;
        private Node _pNode;
    }
}